package w20rest.java;

import org.junit.Test;
import org.springframework.web.client.support.RestGatewaySupport;
import org.springframework.web.util.UriComponentsBuilder;

public class DeleteClient extends RestGatewaySupport {

    public static final String AP = "http://localhost:8888/";

    @Test
    public void test() {

//        testDeleteCustomer();
        testDelete3Customers();

    }

    private void testDelete3Customers() {
        sendDeleteCustomerRequest(1);
        sendDeleteCustomerRequest(2);
        sendDeleteCustomerRequest(3);
    }

    private void testDeleteCustomer() {
        sendDeleteCustomerRequest(5);
    }

    private void sendDeleteCustomerRequest(int id) {
        String uri = AP;
        uri += "customer/" + id;
        final UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromUriString(uri);
        final String uriString = uriComponentsBuilder.build().encode().toUriString();
        System.out.println(uriString);
        getRestTemplate().delete(uriString);
        System.out.println("delete complete " + id);
    }

}